<template>
  <div>
    <el-table
      class="table"
      v-loading="isLoading"
      :data="tableData"
      ref="multipleTable"
      @selection-change="handleSelectionChange"
      border
      :header-cell-style="{
        backgroundColor: '#3963fd',
        color: '#fff',
        'text-align': 'center',
      }"
      style="width: 100%; margin-top: 20px"
    >
      <template slot="empty">
        <img src="@/assets/imgs/暂未数据.png" alt style="margin-top: 104px" />
        <p style="margin-top: 15px; margin-bottom: 104px">暂未有数据</p>
      </template>
      <el-table-column type="selection" width="40"></el-table-column>
      <el-table-column type="serial_no" width="60" label="序号">
        <template slot-scope="scope">
          <div
            class="lattice"
            @click="goInvolume(scope.row.id)"
            style="color: blue; backgroundcolor: red; cursor: pointer"
          >
            {{ scope.row.serial_no }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        width="220"
        prop="archives_no"
        label="档案号"
        align="center"
      >
      </el-table-column>

      <el-table-column align="left" prop="title" label="案卷题名">
      </el-table-column>
      <el-table-column
        width="180"
        prop="start_date"
        label="起止日期"
        align="center"
      >
      </el-table-column>
      <el-table-column align="center" width="60" prop="page_num" label="页次">
      </el-table-column>
      <el-table-column
        align="center"
        width="60"
        prop="word_material"
        label="文字材料"
      >
      </el-table-column>
      <el-table-column align="center" width="60" prop="blueprint" label="蓝图">
      </el-table-column>
      <el-table-column
        width="90"
        align="center"
        prop="store_period"
        label="保管期限"
      >
      </el-table-column>
      <el-table-column width="60" align="center" prop="remark" label="备注">
      </el-table-column>
      <el-table-column width="60" align="center" prop="cabin_no" label="柜号">
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="current_page"
        :page-sizes="pageSizeArr"
        :page-size="per_page"
        layout="total, sizes, prev, pager, next"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import commonInfo from "@/utils/common";
import { BookTitles, borrowBookTitles } from "../../../api/jurisdiction/index";
export default {
  data() {
    return {
      tableData: [],
      //申请时长
      displayData: false,
      //选择器
      multipleSelection: [],
      current_page: 20,
      //分页
      pageSizeArr: JSON.parse(JSON.stringify(commonInfo.pageSizeArr)),
      per_page: 10,
      total: 0,
      isLoading: true,
      iDS: {
        book_title_approval_id: "",
        keyword: "",
        per_page: "",
      },
      iDS2: {
        approval_borrow_id: "",
        keyword: "",
        per_page: "",
      },
    };
  },
  methods: {
    //多选
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    //分页
    handleCurrentChange(val) {
      this.pageNo = val;
      this.$emit("getList");
    },
    //分页
    handleSizeChange(val) {
      this.pageSize = val;
      this.$emit("getList");
    },
    async loadData() {
      this.iDS.book_title_approval_id = this.$route.query.id;
      let res = await BookTitles(this.iDS);
      console.log(res);
      this.tableData = res.data.data.data;
      this.isLoading = false;
    },
    async loadData2() {
      this.iDS2.approval_borrow_id = this.$route.query.id;
      let res = await borrowBookTitles(this.iDS2);
      console.log(res);
      this.tableData = res.data.data.data;
      this.isLoading = false;
    },
    goInvolume(id) {
      this.$router.push({
        path: "/app/common/children/AppCom",
        query: {
          id: id,
        },
      });
    },
  },
  created() {
    let type = this.$route.query.type;
    console.log(type);
    if (type == 1) {
      this.loadData();
    } else if (type == 2) {
      this.loadData2();
    }
  },
};
</script>

<style scoped lang="less">
/deep/.el-button--mini {
  font-size: 16px !important;
}
</style>